package com.his.common;

import java.awt.Color;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;

import com.his.util.SwingUIUtil;

@SuppressWarnings("all")
public class TJButton extends JButton implements MouseListener {
	public TJButton(String picName, String text, String toolTip) {
		buildButton(picName, text, toolTip, false);
	}

	public TJButton(String picName, String text, String toolTip, boolean flag) {
		buildButton(picName, text, toolTip, flag);
	}

	private void buildButton(String picName, String text, String toolTip,
			boolean flag) {
		if(!"".equals(picName)){
			setIcon(new ImageIcon(SwingUIUtil.getImagePath(picName)));
		}
		setText(text);
		setToolTipText(toolTip);
		if (flag) {
			setContentAreaFilled(false);
			setHorizontalTextPosition(0);
			setVerticalTextPosition(3);
		}
		addMouseListener(this);
	}

	public void mouseClicked(MouseEvent me) {
	}

	public void mousePressed(MouseEvent me) {
	}

	public void mouseReleased(MouseEvent me) {
	}

	public void mouseEntered(MouseEvent me) {
		setForeground(new Color(156, 126, 66));
		setBackground(new Color(234, 223, 203));
	}

	public void mouseExited(MouseEvent me) {
		setForeground(new Color(87, 87, 47));
		setBackground(new Color(231, 215, 183));
	}
}